<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:g="http://giava.by/common/base"
	template="/WEB-INF/layout/t.xhtml">
	<ui:define name="title">
		<h:outputText value="Lista Risorse" />
	</ui:define>
	<ui:define name="roles">
		<f:attribute name="roles" value="resource" />
	</ui:define>
	<ui:define name="content">
		<h:form id="central">
			<center>
				<p:panel header="Lista Risorse">

					<h:panelGrid columns="5">
						<h:outputLabel for="nome" value="Nome:" />
						<h:inputText id="nome"
							value="#{resourceController.search.obj.name}" />

						<h:outputLabel for="tipo" value="Tipo di risorsa:"
							rendered="#{loginController.admin}" />
						<h:selectOneMenu id="tipo"
							value="#{resourceController.search.obj.type}"
							rendered="#{loginController.admin}">
							<f:selectItems value="#{resourceItems}"
								rendered="#{loginController.admin}" />
						</h:selectOneMenu>
						<h:outputLabel for="tipo2" value="Tipo di risorsa:"
							rendered="#{loginController.user}" />
						<h:outputText value="Immagini " id="tipo2"
							rendered="#{loginController.user}" />
						<p:commandButton action="#{resourceController.reloadAjax}"
							value="Cerca" ajax="true" immediate="false"
							update="resourcesList" rendered="#{loginController.admin}" />
					</h:panelGrid>
					<br />
					<p:dataTable id="resourcesList" rowIndexVar="rowIndex" var="r"
						value="#{resourceController.model}"
						rows="#{resourceController.pageSize}" paginator="true"
						dynamic="true">
						<p:column width="50">
							<center>
								<h:outputText value="#{rowIndex+1} " />
							</center>
						</p:column>
						<p:column>
							<f:facet name="header">
								<h:outputText value="nome" />
							</f:facet>
							<h:outputText value="#{r.name}" />
						</p:column>
						<p:column>
							<f:facet name="header">
								<h:outputText value="anteprima" />
							</f:facet>
							<center>
								<h:graphicImage value="/img/#{r.name}"
									rendered="#{r.type eq 'img'}"
									width="#{g:imageWidthProportionalUrl('img/'.concat(r.name),100,100)}"
									height="#{g:imageHeightProportionalUrl('img/'.concat(r.name), 100, 100)}" />

								<h:outputLink target="_blank"
									value="#{request.contextPath}/docs/#{r.name}"
									rendered="#{r.type eq 'docs'}">
									<h:outputText value="vedi" />
								</h:outputLink>

								<h:outputLink target="_blank"
									value="#{request.contextPath}/js/#{r.name}"
									rendered="#{r.type eq 'js'}">
									<h:outputText value="vedi" />
								</h:outputLink>

								<h:outputLink target="_blank"
									value="#{request.contextPath}/css/#{r.name}"
									rendered="#{r.type eq 'css'}">
									<h:outputText value="vedi" />
								</h:outputLink>
							</center>
						</p:column>
						<p:column>
							<f:facet name="header">
								<h:outputText value="modifica" />
							</f:facet>
							<center>
								<h:commandLink value="modifica"
									action="#{resourceController.modElement}" />
							</center>
						</p:column>
					</p:dataTable>
				</p:panel>
				<br /> <br />
				<h:panelGrid columns="2">
					<h:commandButton action="#{resourceController.addElement}"
						value="Aggiungi" />
					<h:commandButton action="#{resourceController.backPage}"
						value="Indietro" rendered="false" />
				</h:panelGrid>
			</center>
		</h:form>

	</ui:define>
</ui:composition>